#include "bottommenu.h"

BottomMenu::BottomMenu(sf::RenderWindow& window)
{

    day = 0;

    int outlineThickness = 3;
    xPos = outlineThickness;
    yPos = window.getSize().y *.8;

    boxWidth = window.getSize().x *.794;
    boxHeight = window.getSize().y *.195;

    fontSize = 20;

    menuRect.setSize(sf::Vector2f(boxWidth,boxHeight));
    menuRect.setPosition(xPos,yPos);
    menuRect.setFillColor(sf::Color::Black);
    menuRect.setOutlineThickness(outlineThickness);
    menuRect.setOutlineColor(sf::Color::White);

    font.loadFromFile("resources/arial.ttf");

    messageText.setString("Bottom Menu");
    messageText.setFont(font);
    messageText.setCharacterSize(fontSize);
    messageText.setColor(sf::Color::Green);
    messageText.setPosition(xPos + boxWidth / 3 - messageText.getGlobalBounds().width / 3 , yPos);   //ctor

    energyText.setFont(font);
    energyText.setCharacterSize(fontSize);
    energyText.setColor(sf::Color::White);
    energyText.setPosition(xPos + 25, yPos + 25);

    suppliesText.setFont(font);
    suppliesText.setCharacterSize(fontSize);
    suppliesText.setColor(sf::Color::White);
    suppliesText.setPosition(xPos + 25, yPos + 60);

    dayText.setFont(font);
    dayText.setCharacterSize(fontSize);
    dayText.setColor(sf::Color::White);
    dayText.setPosition(xPos + 25, yPos + 105);

//ctor
}

BottomMenu::~BottomMenu()
{
    //dtor
}

void BottomMenu::Update(Player* p){
    //std::cout << "called menu update" << std::endl;
    std::string str = Utility::toString(p->getEnergy());
    energyText.setString("Energy: " + str);

    str = Utility::toString(p->getSupplies());
    suppliesText.setString("Supplies: " + str);

    dayText.setString("Day: " + Utility::toString(day));
}

void BottomMenu::Render(sf::RenderWindow& window){

        window.draw(menuRect);
        //window.draw(messageText);
        window.draw(energyText);
        window.draw(suppliesText);
        window.draw(dayText);

}

void BottomMenu::changeDay(int d){
    day += d;
}
